package com.hzw.jdbc.preparedStatementTest;

import com.hzw.utils.JdbcUtil;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

public class InsertDemo01 {
    public static void main(String[] args) throws SQLException {

        Connection connection = JdbcUtil.getConnection();
        String sql="INSERT INTO `user` (`username`,`password`) VALUES (?,MD5(?))";
        PreparedStatement preparedStatement = connection.prepareStatement(sql);

        preparedStatement.setString(1,"tom02");
        preparedStatement.setString(2,"123456");

        int i = preparedStatement.executeUpdate();
        if(i>0){
            System.out.println("插入成功");
        }
        JdbcUtil.release(connection,preparedStatement,null);
    }

}
